#ifndef CINPUTMANAGER_H_
#define CINPUTMANAGER_H_

#include <D3D11.h>
#include <D3DX11.h>

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib")

#include <dinput.h>
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

#define LEFTMOUSE_BUTTON 0
#define RIGHTMOUSE_BUTTON 1

class CInputManager
{

	CInputManager();
	~CInputManager();
	CInputManager(const CInputManager&);
	CInputManager& operator=(const CInputManager&);


	IDirectInput8* m_pDIn;
	IDirectInputDevice8* m_pKeyboard;
	IDirectInputDevice8* m_pMouse;
	DIMOUSESTATE m_MouseState;
	DIMOUSESTATE m_OldMouseState;

	BYTE m_Keys[256];
	bool m_KeyState[256];
	bool m_OldKeyState[256];
	HWND m_hWnd;

public:

	static CInputManager* GetInstance();

	bool InitKeyboard(HWND hWnd, HINSTANCE hInstance, bool bIsExclusive);
	bool InitMouse(HWND hWnd, HINSTANCE hInstance, bool bIsExclusive);
	bool InitDirectinput(HWND hWnd, HINSTANCE hInstance, bool bMouseExclusive, bool bKeyboardExclusive);
	void ShutDownDirectInput();
	void ReadDevices();
	void ClearInput();
	void AquireAll();
	void UnacquireAll();

	bool KeyDown(unsigned char ucDIKey);
	bool KeyPressed(unsigned char ucDIKey);
	bool KeyPressedEx(unsigned char ucDIKey);
	bool KeyUp(unsigned char ucDIKey);
	bool KeyReleased(unsigned char ucDIKey);
	bool KeyReleasedEx(unsigned char ucDIKey);
	bool CheckKeys(unsigned char& c);
	char CheckBufferedKeysEx();
	//unsigned char GetDIKCode();
	//unsigned char GetBufferedDIKCodeEx();
	bool MouseButtonDown(unsigned char ucButton);
	bool MouseButtonPressed(unsigned char ucButton);
	bool MouseButtonPressedEx(unsigned char ucButton);
	bool MouseButtonUp(unsigned char ucButton);
	bool MouseButtonReleased(unsigned char ucButton);
	bool MouseButtonReleasedEx(unsigned char ucButton);
	//int	MouseCheckButtons();
	//int	MouseCheckBufferedButtonsEx();
	long MouseGetPosX();
	long MouseGetPosY();
	long MouseWheelMovement();
	//int	MouseGetNumButtons();

	char* GetKeyName(unsigned char scanCode);
	void UpdateInput();

	void SetMouseXPos(long nPosX);
	void SetMouseYPos(long nPosY);

};


#endif